const webpack = require("webpack");
const ReactRefreshWebpackPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const webpackBase = require("./webpack.config.base");
const { port, sourceDir, distDir, staticsDir, rootPath, env } = require("./app.config.js");

module.exports = webpackBase(sourceDir, distDir, staticsDir, {
  devtool: 'source-map',
  entry: {
    index: rootPath(sourceDir, "index.js"),
  },
  plugins: [
    new ReactRefreshWebpackPlugin()
  ],
  devServer: {
    compress: true,
    port,
    open: true,
    static: rootPath(staticsDir),
    proxy: {
      "/dt-platform": {
        target: env === 'online' ? 'https://www.dt-pf.com' : `https://platform-${env}.dtedu.com`,
        secure: true,
        ws: true,  //代理websockets
        changeOrigin: true // 虚拟的站点需要更管origin
      }
    }
  }
});